/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sessionBeans;

import entity.Feedback;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Minh Luc
 */
@Stateless
public class FeedbackFacade extends AbstractFacade<Feedback> implements FeedbackFacadeLocal {

    @PersistenceContext(unitName = "WebBasedClaimProcessing-ejbPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public FeedbackFacade() {
        super(Feedback.class);
    }

    public List<Feedback> findByUserIdSend(Integer UserIdSend) {
        String sQuery = "SELECT f FROM Feedback f WHERE f.userSend.userId = :UserIdSend  ORDER BY f.feedbackDate DESC";
        Query query = em.createQuery(sQuery);
        query.setParameter("UserIdSend", UserIdSend);
        return query.getResultList();
    }
}
